class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-09-18",
      revision: "769a5959a9647800a3f7221611a260881ce4ac6e"
  version "2021-09-18"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "e294e14d798d2bb1ab34cc4225476228d43b7805645ee78d3947f33b488777df"
    sha256 cellar: :any_skip_relocation, big_sur:       "eff86b38ea16a383ac82390bd615cfcdc866be0513adcc02180b224ea2095893"
    sha256 cellar: :any_skip_relocation, catalina:      "8df496a1af696ccedf51eb9ee7658cddfde53a236104e54533042757b00a84c5"
    sha256 cellar: :any_skip_relocation, mojave:        "656339932777a55f59ce97c2f650ffd98ca14b75b02b6b1faab233ecc3d9ec89"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "902d59482b805db913a3036885922df89dc26a34b15c14fa603676c60fcfc5de"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
